const projectData = {
    'name': 'newDemo',
    'fileData': [{
            'name': 'css',
            'type': 'dir'
        },
        {
            'name': 'script',
            'type': 'dir'
        },
        {
            'name': 'images',
            'type': 'dir'
        },
        {
            'name': 'index.html',
            'type': 'file',
            'contents': '<!DOCTYPE html>\n\t<html lang="en">\n\t<head>\n\t<meta charset="UTF-8">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\t<meta http-equiv="X-UA-Compatible" content="ie=edge">\n\t<title>Document</title>\n\t</head>\n\t<body>\n\t</body>\n\t</html>'
        }
    ]
};
const fs = require("fs");
if (projectData.name) {
    fs.mkdirSync(projectData.name)
    // console.log("已创建目录")
    let fileData = projectData.fileData;
    if (fileData && fileData.forEach) {
        fileData.forEach(function (f) {
            f.path = projectData.name + "/" + f.name;
            f.contents = f.contents || "";
            switch (f.type) {
                case "file":
                    fs.writeFileSync(f.path, f.contents);
                    break;
                case "dir":
                    fs.mkdirSync(f.path);
                    break;
                default:
                    break;
            }
        })
    } else {
        console.log("已创建")
    }
} else {
    console.log("已创建")
}